using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.BranchStatistics
{
    public partial class guiIMEIHistoryStatistics : THSERPScreen
    {
        private ICReceiptsInfo ICReceiptsObject;
        private ICTransfersInfo ICTransferReceiptsObject;
        private BRPOSsInfo BRPOSsObject;
        private List<ICTransfersInfo> ICTransfersList;

        public guiIMEIHistoryStatistics()
        {
            InitializeComponent();
        }

        public guiIMEIHistoryStatistics(ICReceiptsInfo objReceiptsInfo, 
                                        ICTransfersInfo objTransferReceiptsInfo, 
                                        BRPOSsInfo objPOSsInfo,
                                        List<ICTransfersInfo> lstICTransfers)
        {
            InitializeComponent();

            ICReceiptsObject = objReceiptsInfo;
            ICTransferReceiptsObject = objTransferReceiptsInfo;
            BRPOSsObject = objPOSsInfo;
            ICTransfersList = lstICTransfers;
        }

        private void guiIMEIHistoryStatistics_Load(object sender, EventArgs e)
        {
            //Init lookup edit column
            DataSet ds = (DataSet)THSApp.LookupTables[THSUtil.GetTableNameFromBusinessObjectType(typeof(ICStocksInfo))];
            if (ds.Tables.Count > 0)
            {
                (colFK_ICFromStockID.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit).DataSource = ds.Tables[0];
                (colFK_ICToStockID.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit).DataSource = ds.Tables[0];
            }

            if (ICReceiptsObject != null)
            {
                fld_txtICReceiptNo.Text = ICReceiptsObject.ICReceiptNo;
                fld_txtICReceiptCreatedUser.Text = ICReceiptsObject.AACreatedUser;
                fld_dteICReceiptStartDate.DateTime = ICReceiptsObject.ICReceiptStartDate;

                APInvoiceInsInfo objInvoiceInsInfo = (APInvoiceInsInfo)new APInvoiceInsController().GetObjectByID(ICReceiptsObject.FK_APInvoiceInID);
                if (objInvoiceInsInfo != null)
                {
                    fld_txtAPInvoiceInNo.Text = objInvoiceInsInfo.APInvoiceInDocumentNo;
                    fld_txtAPInvoiceInCreatedUser.Text = objInvoiceInsInfo.AACreatedUser;
                    fld_dteAPInvoiceInCreatedDate.DateTime = objInvoiceInsInfo.APInvoiceInStartDate;
                }
            }
            if (ICTransferReceiptsObject != null)
            {
                fld_txtICTransferReceiptNo.Text = ICTransferReceiptsObject.ICTransferNo;
                fld_txtICTransferCreatedUser.Text = ICTransferReceiptsObject.AACreatedUser;
                fld_dteICTransferReceiptStartDate.DateTime = ICTransferReceiptsObject.ICTransferStartDate;
            }
            if (BRPOSsObject != null)
            {
                fld_txtBRPOSNo.Text = BRPOSsObject.BRPOSNo;
                fld_txtBRPOSCreatedUser.Text = BRPOSsObject.AACreatedUser;
                fld_dteBRPOSStartDate.DateTime = BRPOSsObject.BRPOSStartDate;
            }
            if (ICTransfersList != null)
            {
                fld_dgcICTransfers.DataSource = ICTransfersList;
            }
        }
    }
}